#include <huniplacer_3d/CrateContent.h>

#include <GL/gl.h>
#include <GL/freeglut.h>

CrateContent::CrateContent(CrateModel* crate, int index, point3 location, point3 size, float r, float g, float b) : 
					Picking("Content"), 
					crate(crate), index(index),
					location(location), size(size) {
	color[0] = r;
	color[1] = g;
	color[2] = b;
}

void CrateContent::change_color(float r, float g, float b) {
	color[0] = r;
	color[1] = g;
	color[2] = b;
}

void CrateContent::draw() {
	glPushMatrix();
	
	glTranslatef(location.x, location.y, location.z);
	
	glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
	glGetDoublev(GL_PROJECTION_MATRIX, projection);
	glGetIntegerv(GL_VIEWPORT, viewport);
	
	set_color3f(color[0], color[1], color[2]);
	glBegin(GL_QUADS);
		glVertex3f(-size.x/2, size.y/2, -size.z/2);
		glVertex3f(-size.x/2, size.y/2, size.z/2);
		glVertex3f(size.x/2, size.y/2, size.z/2);
		glVertex3f(size.x/2, size.y/2, -size.z/2);
	glEnd();
			
	glPopMatrix();
}
